<%@ page import="java.util.List" %>
<%@ page import="com.offcn.entity.Student" %><%--
  Created by IntelliJ IDEA.
  User: 皇陆洋
  Date: 2021/11/19
  Time: 20:26
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>Title</title>
    <style>
        #in{
            width: 50px;
            height: 30px;
            position: relative;
            background-color: chartreuse;
            top: 30px;
            left: 1100px;
        }
    </style>
</head>
<body>
<jsp:include page="top.jsp"></jsp:include>
<div id="in"><a href="insert.jsp">添加</a></div>
<center>
    <form action="student">
        姓名：<input type="text" name="name" style="width: 80px">
        性别：<select name="sex" id="">
        <option value="-1">请选择</option>
        <option value="0">男</option>
        <option value="1">女</option>
    </select>
        <input type="submit" value="搜索">
    </form>
</center>
<table border="1px" width="60%" align="center" cellspacing="0">
    <caption><b style="font-size: 50px">学生信息表</b></caption>
    <tr>
        <th>学号</th>
        <th>姓名</th>
        <th>年龄</th>
        <th>性别</th>
        <th>电话</th>
        <th>生日</th>
        <th>头像</th>
        <th colspan="2">操作</th>
    </tr>
    <c:forEach items="${list}" var="s" varStatus="i">
        <tr align="center">
            <td>${s.sid}</td>
            <td>${s.name}</td>
            <td>${s.age}</td>
            <td>${s.sex}</td>
            <td>${s.tel}</td>
            <td>${s.bir}</td>
            <td>
                <img src="/pic/${s.spic}" height="50px" alt="">
            </td>
            <td><a href="delete?id=${s.sid}">删除</a></td>
            <td><a href="update?id=${s.sid}">修改</a></td>
        </tr>
    </c:forEach>
</table>
<center>
    <a href="student?curPage=1&name=${name}&sex=${sex}">首页</a>
    <a href="student?curPage=${p.prevPage}&name=${name}&sex=${sex}">上一页</a>
    <c:forEach begin="1" end="${p.endPage}" var="n">
        <a href="student?curPage=${n}&name=${name}&sex=${sex}">${n}</a> &nbsp;&nbsp;&nbsp;
    </c:forEach>
    <a href="student?curPage=${p.nextPage}&name=${name}&sex=${sex}">下一页</a>
    <a href="student?curPage=${p.endPage}&name=${name}&sex=${sex}">尾页</a>
    <span>${p.curPage}/${p.endPage}</span>
    <span>总记录数：${p.rows}</span>
    <input size="3" id="pageNum"/>
    <input type="button" value="跳转" onclick="jumpPage(${p.endPage})"/>
</center>
</body>
<script>
    function jumpPage(n){
        var num = document.getElementById("pageNum").value;
        if(num>=1&&num<=n){
            location.href="student?curPage="+num+"&name=${name}&sex=${sex}";
        }else {
            alert("请输入有效页码");
        }
    }
</script>
</html>
